package com.yangye.picommon.utils;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * Created by yangye on 2019/7/10
 */
public class SecurityUtil {

	public static String getUsername() {
		Object details = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		if (details instanceof UserDetails) {
			return ((UserDetails) details).getUsername();
		}
		return null;
	}
}
